package com.hbun.cxcy.controller;


import com.hbun.cxcy.common.utils.PageUtils;
import com.hbun.cxcy.common.utils.R;
import com.hbun.cxcy.entity.MacPeople;
import com.hbun.cxcy.service.MacPeopleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;
import java.util.Map;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author mahaunyu
 * @since 2022-01-24
 */
@CrossOrigin
@RestController
@RequestMapping("/cxcy/mac-people")
public class MacPeopleController {
    @Autowired
    private MacPeopleService macPeopleService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    //@RequiresPermissions("cxcyweb:macpeople:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = macPeopleService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    //@RequiresPermissions("cxcyweb:macpeople:info")
    public R info(@PathVariable("id") Long id){
        MacPeople macPeople = macPeopleService.getById(id);

        return R.ok().put("macPeople", macPeople);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    //@RequiresPermissions("cxcyweb:macpeople:save")
    public R save(@RequestBody MacPeople macPeople){
        macPeopleService.saveWithCustom(macPeople);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    //@RequiresPermissions("cxcyweb:macpeople:update")
    public R update(@RequestBody MacPeople macPeople){
        macPeopleService.updateByIdWithCoustom(macPeople);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    //@RequiresPermissions("cxcyweb:macpeople:delete")
    public R delete(@RequestBody Long[] ids){
        macPeopleService.removeByIdsWithCustom(Arrays.asList(ids));

        return R.ok();
    }
}

